package com.matt.domain;
import com.matt.foundation.constant.FeedsConstant;
import com.matt.commons.model.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2017/11/27
 * *******************************
 */
@Table(name = "feeds")
@Data
@Entity
@EqualsAndHashCode(callSuper = false)
public class Feeds extends Model{

    @Column(name = "uid", columnDefinition = "varchar(32) COMMENT '员工id'")
    private String staffId = "";

    @Column(columnDefinition = "varchar(32)  COMMENT '宝宝id'")
    private String childrenId = "";

    @Column(columnDefinition = "varchar(32)  COMMENT '园区id'")
    private String place = "";

    @Column(columnDefinition = "varchar(255)  COMMENT '事件'")
    private String event = "";

    @Column(columnDefinition = "varchar(255)  COMMENT '类型'")
    private String eventType;

    @Column(columnDefinition = "varchar(255)  COMMENT '标题'")
    private String title;

    @Column(columnDefinition = "varchar(255)  COMMENT '内容'")
    private String content;

    @Column(columnDefinition = "varchar(255)  COMMENT '图片'")
    private String images;

    @Column(columnDefinition = "varchar(255)  COMMENT '视频'")
    private String videos;

    @Column(columnDefinition = "varchar(255)  COMMENT '关联id'")
    private String linkId;

    @Column(columnDefinition = "varchar(255) COMMENT '周排课网页Url'")
    private String url;

    ///// patch for feeds system
    @Column(columnDefinition = "varchar(20) COMMENT '老师姓名'")
    private String teacherName;

    @Column(columnDefinition = "varchar(255) COMMENT '老师头像'")
    private String teacherImg;

    @Column(columnDefinition = "varchar(10) COMMENT '类型 1晨检签到2观测记录3托班月评4排课通知5课堂评测6SAT月评7生日会'")
    private Integer type;

    @Column(columnDefinition = "varchar(255) COMMENT '类型中文'")
    private String typeVal;

    ///// patch for feeds system end

    @Column
    private Date created = new Date();


    public static Feeds of(String staffId, String childrenId, String place, String event, String eventType, String title, String content, String images, String videos, String linkId,String url){
        Feeds feeds = new Feeds();
        feeds.setStaffId(staffId);
        feeds.setChildrenId(childrenId);
        feeds.setPlace(place);

        feeds.setEvent(event);
        feeds.setEventType(eventType);

        String typeVal = "";
        int i = 0;
        try {
            i = Integer.parseInt(eventType);
            switch (eventType) {
                case FeedsConstant.HEALTH_CHECK:
                    typeVal = "晨检签到";
                    break;
                case FeedsConstant.NURSERY:
                    typeVal = "托班观测记录";
                    break;
                case FeedsConstant.NURSERY_MONTH_EVALUATE:
                    typeVal = "托班月评";
                    break;
                case FeedsConstant.PLAN_COURSE:
                    typeVal = "排课";
                    break;
                case FeedsConstant.STA_EVALUATE_END:
                    typeVal = "SAT课堂评测";
                    break;
                case FeedsConstant.STA_EVALUATE_MONTH:
                    typeVal = "SAT月评";
                    break;
                case FeedsConstant.BIRTHDAY_MEETING:
                    typeVal = "园区生日会";
                    break;
                case FeedsConstant.EVALUATE_RECORD:
                    typeVal = "评测报告";
                    break;
                case FeedsConstant.OBSERVATION_NEW:
                    typeVal = "课程观测报告_新";
                    break;
                case FeedsConstant.EVALUATE_RECORD_V2:
                    typeVal = "心里行为评测报告_新";
                    break;
                case FeedsConstant.EVALUATE_RECORD_HEALTH:
                    typeVal = "儿保评测";
                    break;
                case FeedsConstant.DEVELOP_REVIEW:
                    typeVal = "发展检表记录";
                    break;
                case FeedsConstant.GROWTH_OBSERVATION:
                    typeVal = "成长观察记录";
                    break;
            }
            feeds.setType(i);
            feeds.setTypeVal(typeVal);
        } catch (Exception e) {
            feeds.setType(i);
        }

        feeds.setTitle(title);
        feeds.setContent(content);
        feeds.setImages(images);
        feeds.setVideos(videos);
        feeds.setLinkId(linkId);
        feeds.setUrl(url);
        return feeds;
    }
}
